package cn.itcast.nems.studentrecord.converter;

import cn.itcast.nems.studentrecord.dao.entity.StudentRecord;
import cn.itcast.nems.studentrecord.dto.change.StudentRecordJournalDTO;
import cn.itcast.nems.studentrecord.dto.studentrecord.StudentRecordReferenceDTO;

/**
 * @author liyong
 * create: 2023-11-20 15:07:43
 **/
public class StudentRecordReferenceConverter {

    public static StudentRecordReferenceDTO origin(StudentRecord studentRecord, StudentRecordJournalDTO dto) {
        StudentRecordReferenceDTO result = new StudentRecordReferenceDTO();
        result.setReferenceType(dto.getJournalType());
        result.setReferenceId(dto.getJournalId());
        result.setReferenceLineId(dto.getJournalLineId());
        result.setStudentRecordId(studentRecord.getId());
        result.setClazzId(dto.getOriginClazzId());
        result.setClazzName(dto.getOriginClazzName());
        result.setBizDate(dto.getOriginClazzOutDate().atStartOfDay());
        result.setActualAmountDue(dto.getOriginClazzSettlementAmount());
        return result;
    }

    public static StudentRecordReferenceDTO target(StudentRecord studentRecord, StudentRecordJournalDTO dto) {
        StudentRecordReferenceDTO result = new StudentRecordReferenceDTO();
        result.setReferenceType(dto.getJournalType());
        result.setReferenceId(dto.getJournalId());
        result.setReferenceLineId(dto.getJournalLineId());
        /*
        if (StringUtils.hasText(dto.getOrderId())) {
            result.setReferenceType(ReferenceTypeEnum.ORDER);
            result.setReferenceId(dto.getOrderId());
            result.setReferenceLineId(dto.getOrderLineId());
        }
        */
        result.setStudentRecordId(studentRecord.getId());
        result.setActualAmountDue(studentRecord.getActualAmountDue());
        result.setClazzId(dto.getTargetClazzId());
        result.setClazzName(dto.getTargetClazzName());
        result.setBizDate(dto.getTargetClazzInDate().atStartOfDay());
        return result;
    }

}
